package com.cloud.code.牛客网;

import java.util.*;

public class Test55 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {

            Set<String> set = new TreeSet<>();

            String line = scanner.nextLine();
            String[] split = line.split(",");

            Deque<String> stack = new ArrayDeque<String>();
            List<String> list = new ArrayList<>();
            boolean[] userd = new boolean[split.length];

            dfs(split, split.length, 0, userd, stack, list);

            Collections.sort(list);

            System.out.println(list.get(list.size()-1));
        }


    }

    private static void dfs(String[] split, int length, int depth, boolean[] userd, Deque<String> stack, List<String> list) {

        if (length == depth) {
            list.add(Arrays.toString(new Deque[]{stack}).replaceAll("\\W+", ""));
            return;
        }

        for (int i = 0; i < length; i++) {
            if (userd[i]) {
                continue;
            }
            stack.addLast(split[i]);
            userd[i] = true;
            dfs(split, length, depth + 1, userd, stack, list);
            stack.removeLast();
            userd[i] = false;
        }
    }
}
